let Set = (arr) => {
    let max = 0;
    let maxel = 0;
    for (let i = 0; i < arr.length; i++) {
        let maxs = 0;
        for (let j = 0; j < arr.length; j++) {
            if (arr[i] == arr[j]) {
                maxs++;
            }
        }
        if (maxs > max) {
            max = maxs;
            maxel = arr[i]
        }
    }
    return max > arr.length / 2 ? maxel : -1;
}
console.log(Set([1, 2, 5, 9, 5, 9, 5, 5, 5]))
console.log(Set([3, 2]))
console.log(Set([2, 2, 1, 1, 1, 2, 2]))